const db = require('./config/database')

async function checkTags () {
  try {
    console.log('检查tags字段...')
    const data = await db.query('SELECT id, title, tags FROM novels LIMIT 3')

    data.forEach(novel => {
      console.log(`\n小说: ${novel.title}`)
      console.log('tags原始数据:', novel.tags)
      console.log('tags类型:', typeof novel.tags)

      try {
        if (novel.tags) {
          const parsed = JSON.parse(novel.tags)
          console.log('解析后的tags:', parsed)
        } else {
          console.log('tags为空')
        }
      } catch (e) {
        console.log('JSON解析失败:', e.message)
      }
    })
  } catch (error) {
    console.error('检查失败:', error)
  } finally {
    process.exit(0)
  }
}

checkTags()
